package ym.ecrm.core.dto.systemManagement;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;

import ym.ecrm.core.domain.systemManagement.Organization;

public class OrganizationDTO {

	private long organizationId;
	private String organizationCode;
	private String organizationName;
	private String telephone;
	private String fax;
	private String address;
	
	private long parentOrganizationId;
	
	private String description;
	private String note;
	
	public static void entity2dto(Organization organization, OrganizationDTO organizationDTO){
		try {
			BeanUtils.copyProperties(organizationDTO, organization);
			organizationDTO.setOrganizationId(organization.getId());
			organizationDTO.setOrganizationName(organization.getName());
			if(organization.getParent() != null)
				organizationDTO.setParentOrganizationId(
						organization.getParent().getId());
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		
	}
	
	public static void dto2entity(OrganizationDTO organizationDTO, Organization organization){
		try {
			BeanUtils.copyProperties(organization, organizationDTO);
			organization.setId(organizationDTO.getOrganizationId());
			organization.setName(organizationDTO.getOrganizationName());
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		
	}
	
	public long getOrganizationId() {
		return organizationId;
	}
	public void setOrganizationId(long organizationId) {
		this.organizationId = organizationId;
	}
	public String getOrganizationCode() {
		return organizationCode;
	}
	public void setOrganizationCode(String organizationCode) {
		this.organizationCode = organizationCode;
	}
	public String getOrganizationName() {
		return organizationName;
	}

	public void setOrganizationName(String organizationName) {
		this.organizationName = organizationName;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getFax() {
		return fax;
	}
	public void setFax(String fax) {
		this.fax = fax;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}

	public long getParentOrganizationId() {
		return parentOrganizationId;
	}

	public void setParentOrganizationId(long parentOrganizationId) {
		this.parentOrganizationId = parentOrganizationId;
	}
}
